﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ConversionHelperFactory.cs" company="CodePlex">
//   Copyright © CodePlex 2012
// </copyright>
// <summary>
//   Defines the ConversionHelperFactory type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace DataFrameworkGenerator.Factories
{
    using System;

    using DataFrameworkGenerator.Helpers;
    using DataFrameworkGenerator.Interfaces;

    /// <summary>
    /// Factory to provide the caller with the correct conversion helper based off the configuration.
    /// </summary>
    public static class ConversionHelperFactory
    {
        /// <summary>
        /// Fetches the data type converter.
        /// </summary>
        /// <param name="type">Type of the db.</param>
        /// <returns>Data type converter for the db provided.</returns>
        public static IConversionHelper FetchConversionHelper(DatabaseType type)
        {
            IConversionHelper returnObject;
            switch (type)
            {
                case DatabaseType.Access2003:
                    returnObject = new Access2003ConversionHelper();
                    break;
                case DatabaseType.Oracle:
                    returnObject = new OracleDbConversionHelper();
                    break;
                case DatabaseType.MsSql:
                    returnObject = new MsSqlConversionHelper();
                    break;
                default:
                    throw new NotImplementedException(string.Format("Type {0} is not implemented in the ConversionHelperFactory.", type));
            }

            return returnObject;
        }
    }
}
